package demo10;


public class Singleton implements Cloneable {

    // 私有构造方法
    private Singleton() {}

    // 静态变量声明，并没有赋值
    private static class SingletonHolder {
        private static final Singleton INSTANCE = new Singleton();
    }

    public static Singleton getInstance() {
        return SingletonHolder.INSTANCE;
    }

    @Override
    public Object clone() throws CloneNotSupportedException {
        return SingletonHolder.INSTANCE;
    }
}
